package com.bytech.admin.biz.controller;

import com.bytech.admin.biz.controller.blog.BlogStatController;
import com.bytech.common.biz.entity.base.BaseResult;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bytech.common.biz.controller.base.BasicController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author zhao
 * @Create 2021/8/6 15:28
 */
@Controller
public class IndexController extends BasicController {

    @Resource
    private BlogStatController blogStatController;

    @GetMapping({ "/home", "/" })
    public String toHomePage() {
        return "home";
    }

    @GetMapping("/home/welcome")
    public String toWelcomePage(Model model) {
        Map<String, Integer> serviceInfoMap = blogStatController.getServiceInfo().getData();
        model.addAttribute("serviceInfoMap", serviceInfoMap);
        return "welcome";
    }

    @GetMapping("/error/{errorCode}")
    public String toErrorPage(@PathVariable("errorCode") String errorCode) {
        return "/error/" + errorCode;
    }
}
